package com.abel.bigwater.data

import com.abel.bigwater.data.jnrq.JnrqPacket
import com.abel.bigwater.data.jnrq.JnrqSettings
import com.abel.bigwater.data.jnrq.PacketType
import com.abel.bigwater.data.jnrq.TimingData
import io.netty.buffer.Unpooled
import org.joda.time.DateTime
import org.junit.Test
import org.junit.runner.RunWith
import org.slf4j.LoggerFactory
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner

@RunWith(SpringJUnit4ClassRunner::class)
@SpringBootTest(classes = arrayOf(TimingDataTests::class))
class TimingDataTests {
    @Test
    fun test01Data() {
        val p = JnrqPacket().apply {
            packetType = PacketType.AdjustTime
            devAddrInt = 0x11223344
            data = TimingData().apply {
                serverTime = DateTime.now()
            }
        }

        val buf = Unpooled.buffer()
        p.fillBuffer(buf)

        lgr.info("\n${BcdString.create(buf, buf.readableBytes()).bcdStringBlank()}")
    }

    companion object {
        val lgr = LoggerFactory.getLogger(TimingDataTests::class.java)
    }
}